﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace UDFDesign.GUIComponent.CustomControl
{
    public partial class PropertiesPanel : UserControl
    {
        private SupFormControlMappingObjectcs controlMapping;

        public PropertiesPanel()
        {
            InitializeComponent();
        }

        public void setControl(SupFormControlMappingObjectcs control)
        {
            if (control == null)
            {
                propertyGrid.SelectedObject = null;
                this.Enabled = false;
                return;
            }
            this.controlMapping = control;
            
            propertyGrid.SelectedObject= control;
            this.Enabled = true;
        }

        public void refreshInfo()
        {
            propertyGrid.Refresh();
        }

        private void deleteBtn_Click(object sender, EventArgs e)
        {
            controlMapping.Control.delete();
            setControl(null);
        }

        
        private void applyChanged(object s, PropertyValueChangedEventArgs e)
        {

            controlMapping.applyChanges();
            /*
            if (!mappingObject.checkValidProperties())
            {
                e.ChangedItem.PropertyDescriptor.SetValue(propertyGrid.SelectedObject, e.OldValue);
                return;
            }

            mappingObject.applyChanges();

            propertyGrid.Refresh();
            */
        }
        
        
    }


}
